import React from 'react';
import PropTypes from 'prop-types';
import { Form, Button } from 'antd';
import Locale from '@/utils/locale';
import CompanyDepart from '@/components/CompanyDepart';

const { locale } = new Locale('zzjgfx');

// const { Option } = Select;

const SearchForm = ({ form, handleSubmit }) => {
    const { getFieldDecorator } = form;
    return (
        <Form
            layout="inline"
            onSubmit={e => {
                e.preventDefault();
                form.validateFieldsAndScroll((err, values) => {
                    if (!err) {
                        handleSubmit(values);
                    }
                });
            }}
        >
            <Form.Item label="选择公司部门">
                {getFieldDecorator('companyId', {
                    rules: [
                        {
                            message: 'Please input your username!'
                        }
                    ]
                })(<CompanyDepart />)}
            </Form.Item>
            <Form.Item>
                <Button type="primary" icon="search" htmlType="submit">
                    {locale('form.search', false)}
                </Button>
            </Form.Item>
        </Form>
    );
};

SearchForm.propTypes = {
    /**
     * 查询时的回调函数
     */
    handleSubmit: PropTypes.func.isRequired
};

export default Form.create()(SearchForm);
